package cn.study.vue_project_xxx.controller;


import cn.dev33.satoken.annotation.SaIgnore;
import cn.study.vue_project_xxx.common.result.ResultSet;
import cn.study.vue_project_xxx.entity.dto.RegisterUserDTO;
import cn.study.vue_project_xxx.entity.po.TAdmin;
import cn.study.vue_project_xxx.entity.po.UserInfo;
import cn.study.vue_project_xxx.mapper.UserInfoMapper;
import cn.study.vue_project_xxx.service.TAdminService;
import cn.study.vue_project_xxx.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;


import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;


import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (TAdmin)表控制层
 *
 * @author makejava
 * @since 2023-04-25 09:53:15
 */
@Api(tags = "接口")
@RestController
@RequestMapping("/api/v1/tAdmin")
@Slf4j
public class TAdminController {
    /**
     * Service层对象
     */
    @Autowired
    TAdminService tAdminService;

    @Resource
    UserService userService;

    /**
     * 新增管理员用户
     * @param registerUserDTO 管理员信息
     * @return ResultSet
     */
    @SaIgnore
    @PostMapping("/registerAdminInfo")
    public ResultSet<Boolean> registerAdminInfo(@RequestBody RegisterUserDTO registerUserDTO) {
        return ResultSet.success(tAdminService.addAdmin(registerUserDTO));
    }

    /**
     * 删除管理员用户
     * @param
     * @return ResultSet
     */
    @PostMapping("/deleteUserLogin")
    public ResultSet<Boolean> deleteUserLogin(@RequestParam List<Long> userIds) {
        return ResultSet.success(tAdminService.deleteAdmin(userIds));
    }

    /**
     * 修改管理员用户
     * @param
     * @return ResultSet
     */
    @PostMapping("/updateAdmin")
    public ResultSet<Boolean> updateAdmin(@RequestBody TAdmin admin) {
        return ResultSet.success(tAdminService.updateAdmin(admin));
    }

    /**
     * 查询管理员用户列表
     * @param
     * @return ResultSet
     */
    @PostMapping("/selectAdmins")
    public ResultSet<Page<TAdmin>> selectAdmins(@RequestParam List<Long> userIds, Integer currentPage, Integer pageSize) {
        Page<TAdmin> page = new Page<>(currentPage, pageSize);
        return ResultSet.success(tAdminService.selectUsers(page,userIds));
    }
}

